package com.edyd.customer.api.controller;

import com.edyd.customer.api.domain.Client;
import com.edyd.customer.api.service.ClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created by Greg.chen on 2016/3/11.
 */
@Controller
public class IndexController {


    @Autowired
    private ClientService clientService;

    @Value("${application.message:Hello World}")
    private String message = "Hello World";

    @RequestMapping("/")
    public String welcome(Map<String, Object> model) {
        List<Client> list = clientService.selectList();
        model.put("clientList", list);
        model.put("time", new Date());
        model.put("message", this.message);
        return "index";
    }


    @RequestMapping(value = "/404", method = RequestMethod.GET)
    public String notFoundPage() {
        return "404";
    }

    @RequestMapping(value = "/500", method = RequestMethod.GET)
    public String errorPage() {

        return "500";
    }

}
